home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / dviware / umddvi / lib / conv.c < prev    next >
C/C++ Source or Header  |  1990-10-01  |  1KB  |  50 lines

  1. /*
  2.  * Copyright (c) 1987 University of Maryland Department of Computer Science.
  3.  * All rights reserved.  Permission to copy for any purpose is hereby granted
  4.  * so long as this copyright notice remains intact.
  5.  */
  6.  
  7. #ifndef lint
  8. static char rcsid[] = "$Header: conv.c,v 1.3 87/06/16 18:27:39 chris Exp $";
  9. #endif
  10.  
  11. /*
  12.  * Conversions.
  13.  */
  14.  
  15. #include "types.h"
  16. #include "conv.h"
  17.  
  18. double    DMagFactor();
  19.  
  20. /*
  21.  * Set a conversion (possibly the global conversion).
  22.  */
  23. void
  24. CSetConversion(c, dpi, usermag, num, denom, dvimag)
  25.     register struct conversion *c;
  26.     int dpi, usermag;
  27.     i32 num, denom, dvimag;
  28. {
  29.     double ddpi = dpi;
  30.  
  31.     c->c_mag = DMagFactor((int) dvimag) * DMagFactor(usermag);
  32.     c->c_dpi = ddpi;
  33.  
  34.     /*
  35.      * The conversion facture is figured as follows:  there are exactly
  36.      * num/denom DVI units per decimicron, and 254000 decimicrons per
  37.      * inch, and dpi pixels per inch.  Then we have to adjust this by
  38.      * the stated magnification. 
  39.      */
  40.     c->c_fromsp = (num / 254000.0) * (ddpi / denom) * c->c_mag;
  41.  
  42.     /*
  43.      * c->c_tosp is 1/c->c_fromsp, but we will invert the expression
  44.      * above in the hopes of some extra accuracy.
  45.      *
  46.      * IS THIS ANY GOOD?  I NEED A NUMERICAL ANALYST!
  47.      */
  48.     c->c_tosp = (254000.0 / num) * (denom / ddpi) * (1.0 / c->c_mag);
  49. }
  50.